<template>
    <el-card class="box-card">
        <el-form :model="PropertyEditData" :rules="rules" ref="PropertyEditData">
            <el-form-item label="名称" prop="peopertyName">
                <el-input v-model="PropertyEditData.peopertyName"></el-input>
            </el-form-item>
            <el-form-item label="显示文本" prop="peopertyText">
                <el-input v-model="PropertyEditData.peopertyText"></el-input>
            </el-form-item>
        </el-form>
        <el-col :span="24" class="toolPage">
            <el-button type="primary" @click="submitForm('PropertyEditData')">更新商品</el-button>
            <el-button style="float:right;" @click="returnPropertyList">返回</el-button>
        </el-col>
    </el-card>
</template>
<script>
    export default {
        data() {
            return {
                PropertyEditData: {
                    peopertyName: 'origin',
                    peopertyText: '产地'
                },
                rules: {
                    peopertyName: [
                        { required: true, message: '请输入名称', trigger: 'change blur' },
                    ],
                    peopertyText: [
                        { required: true, message: '请输入显示文本', trigger: 'change blur' }
                    ],
                }
            }
        },
        methods: {
            returnPropertyList() {
                this.$router.push(`/properties`);
            },
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            }
        }
    }

</script>